package com.lt.accesscontrolmanager.mapper;

import org.apache.ibatis.annotations.Param;

public class SqlBuilder {
    public String buildSelectByBuildingId(@Param("buildingId") String buildingId) {
        StringBuilder sql =
                new StringBuilder
                        ("SELECT a.*, b.name as name FROM access_control_device a LEFT JOIN building b ON a.building_id = b.id");
        if (buildingId != null && !buildingId.isEmpty()) {
            sql.append(" WHERE a.building_id = #{buildingId}");
        }
        return sql.toString();
    }
}